package com.lagou.study.seckill.service;

import com.lagou.study.seckill.mapper.StockMapper;
import com.lagou.study.seckill.pojo.Stock;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Optional;

@Service
public class StockService {

    @Autowired
    private StockMapper stockMapper;

    public Integer getQuantity(){
        Optional<Stock> result = stockMapper.findById(1);
        Stock stock = result.get();
        return stock.getQuantity();
    }

    public void sumQuantity(){
        stockMapper.updateQuantity();
    }
}
